<template>
  <div class="ad-resetPassword">
    <div class="passwordType" v-if="type === 1">
      <div class="title">
        <span>RETRIEVE PASSWORD </span>
      </div>
      <div class="content type1content">
        <div class="inputOption">
          <el-input v-model="emailAddress" placeholder="Email address">
          </el-input>
        </div>

        <div class="btnsContent mt-40">
          <el-button class="btn btn1" @click="backToLogin">Back</el-button>
          <el-button class="btn btn2" @click="goNextStep">Next Step</el-button>
        </div>
      </div>
    </div>
    <div class="passwordType passwordType2" v-if="type === 2">
      <div class="title">
        <span>RETRIEVE PASSWORD </span>
      </div>
      <div class="content type1content">
        <div class="inputOption" style="margin-bottom: 20px">
          <el-input
            v-model="passwordForm.password"
            placeholder="Enter password"
          >
          </el-input>
        </div>
        <div class="inputOption">
          <el-input
            v-model="passwordForm.confirmPassword"
            placeholder="Confirm password"
          >
          </el-input>
        </div>
        <div class="btnsContent mt-40">
          <el-button class="btn btn2" @click="resetPasswordFn"
            >Confirm</el-button
          >
          <span class="backlogin" @click="backToLogin"> Back to Login</span>
        </div>
      </div>
    </div>
    <div class="passwordType passwordType3" v-if="type === 3">
      <img src="@/assets/images/login/emailSend.png" alt="" class="send" />
      <div class="emailText">
        <p>An email with a password reset link was just sent to</p>
        <div style="text-align: center">{{ emailAddress }}</div>
      </div>

      <div class="step3Content">
        <el-button class="btn btn2" @click="backToLogin">Confirm</el-button>
      </div>
    </div>
  </div>
</template>
<script lang="ts" setup>
import { onMounted, reactive, ref } from 'vue'
import router from '@/router/router'
import { useRouter } from 'vue-router'
const type = ref(1) //1 是输入邮箱验证，3：发送成功 2:重置密码
const emailAddress = ref('ewewe@qq.com')
const passwordForm = reactive({
  password: '',
  confirmPassword: ''
})
const goNextStep = () => {
  // 当前type = 1请求下一步接口，成功后，跳转到邮件发送的弹窗应该同时发送邮件
  type.value = 3
}
const backToLogin = () => {
  router.push('/login')
}
const Router = useRouter()

onMounted(() => {
  const { id } = Router.currentRoute.value?.query
  if (id) {
    type.value = 2
  }
})
const resetPasswordFn = () => {}
</script>
<style lang="scss" scoped>
$color: #15104b;
.ad-resetPassword {
  width: 100%;
  height: 100vh;
  background: $color;
  display: flex;
  align-items: center;
  justify-content: center;
  .passwordType {
    margin: 0 auto;
    width: 840px;
    // height: 312px;
    padding-bottom: 40px;
    border-radius: 20px;
    background: #ffffff;
  }
  .passwordType2 {
    .btnsContent {
      display: flex;
      flex-direction: row;
      align-items: flex-end;
      justify-content: center;
      .backlogin {
        color: $color;
        margin-left: 10px;
        margin-bottom: 6px;
        cursor: pointer;
      }
    }
  }
  .passwordType3 {
    display: flex;
    justify-content: center;
    flex-direction: column;
    align-items: center;
    padding: 40px 0;
    img {
      width: 76px;
      height: 76px;
      margin-bottom: 52px;
    }
    .emailText {
      color: $color;
      font-size: 20px;
      margin-bottom: 52px;
    }
  }
  .title {
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: #333333;
    border-bottom: 1px solid #e4e6ef;
  }

  .content {
    display: flex;
    align-items: center;
    padding-top: 50px;
    flex-direction: column;
  }
  .inputOption {
    width: 540px;
    :deep(.el-input__wrapper) {
      width: 100%;
      height: 54px;
      border-radius: 38px;
      border: 1px solid #333333;
    }
  }

  .btn {
    width: 200px;
    height: 44px;
    font-weight: 600;
    border-radius: 38px;
  }
  .btn1 {
    color: $color;
    background: #eff1f3;
    margin-right: 40px;
  }
  .btn2 {
    color: #ffffff;
    background: $color;
  }
  .mt-20 {
    margin-top: 20px;
  }
  .mt-40 {
    margin-top: 40px;
  }
  .mb-20 {
    margin-bottom: 20px;
  }
  .mb-40 {
    margin-bottom: 40px;
  }
}
</style>
